﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace BYRForum.Binding.Mail
{
    public class MailItem
    {
        private String _title;
        public String Title
        {
            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    NotifyPropertyChanged("Title");
                }
            }
        }

        private string _fontweight;
        public String FontWeight
        {
            get
            {
                return _fontweight;
            }
            set
            {
                if (value != _fontweight)
                {
                    _fontweight = value;
                    NotifyPropertyChanged("FontWeight");
                }
            }
        }

        public string Index { get; set; }

        private string _is_read;
        public string Is_read
        {
            get
            {
                return _is_read;
            }
            set
            {
                if (value != _is_read)
                {
                    _is_read = value;
                    if (value == "true")
                        FontWeight = "Normal";
                    else FontWeight = "Bold";
                    NotifyPropertyChanged("Is_read");
                }
            }

        }


        private String _username;
        public String UserName
        {
            get
            {
                return _username;
            }
            set
            {
                if (value != _username)
                {
                    _username = value;
                    NotifyPropertyChanged("UserName");
                }
            }
        }

        private String _post_time;
        public String Post_time
        {
            get
            {
                return _post_time;
            }
            set
            {
                if (value != _post_time)
                {
                    DateTime dtStart = new DateTime(1970, 1, 1);
                    long lTime = long.Parse(value + "0000000");
                    TimeSpan toNow = new TimeSpan(lTime);
                    DateTime dtResult = dtStart.Add(toNow);

                    _post_time = dtResult.ToString("yyyy-MM-dd HH:mm:ss"); ;

                    NotifyPropertyChanged("Post_time");
                }
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
